package com.niiwoo.civet.account.service;/**
 * Created by DELL on 2017/12/5.
 */

import com.niiwoo.civet.account.dto.common.WithdrawOrderDTO;
import com.niiwoo.civet.account.dto.request.*;
import com.niiwoo.civet.account.dto.response.BankInfoRespDTO;
import com.niiwoo.civet.account.dto.response.WithdrawNotifyResponseDTO;
import com.niiwoo.civet.account.dto.response.WithdrawOrderResponseDTO;
import com.niiwoo.civet.account.dto.response.WithdrawT0CheckResponse;
import com.niiwoo.tripod.lanmao.enums.UserRoleEnum;
import com.niiwoo.tripod.provider.dto.response.PageResponseDTO;

import java.math.BigDecimal;

/**
 * 提现dubbo接口
 *
 * @author xiaoyingping
 * @create 2017-12-05 20:28
 **/
public interface WithdrawDubboService {


    /**
     * 检查是否支持能T0提现
     *
     * @param userId
     * @param userRoleEnum
     * @param withdrawAmount
     * @return
     */
    WithdrawT0CheckResponse checkT0Enable(String userId, UserRoleEnum userRoleEnum, BigDecimal withdrawAmount);

    /**
     * 提交提现申请
     *
     * @param requestDTO
     * @return
     */
    WithdrawOrderDTO submitWithdraw(SubmitWithdrawRequestDTO requestDTO);

    /**
     * 确认提现
     *
     * @param withdrawOrderId
     */
    void confirmWithdraw(Long withdrawOrderId);

    /**
     * 取消提现
     *
     * @param withdrawOrderId
     */
    void cancelWithdraw(Long withdrawOrderId);


    /**
     * 处理申请提现异常回调通知
     *
     * @param withdrawNotifyRequestDTO
     */
    WithdrawNotifyResponseDTO processSubmitWithdrawNotify(WithdrawNotifyRequestDTO withdrawNotifyRequestDTO);

    /**
     * 提现出款成功
     *
     * @param withdrawNotifyRequestDTO
     */
    void withdrawPaymentSuccess(WithdrawNotifyRequestDTO withdrawNotifyRequestDTO);

    /**
     * 提现出款失败
     *
     * @param withdrawNotifyRequestDTO
     */
    void withdrawPaymentFail(WithdrawNotifyRequestDTO withdrawNotifyRequestDTO);

    /**
     * 分页查询提现订单列表
     *
     * @param withdrawOrderQueryRequest
     * @return
     */
    PageResponseDTO<WithdrawOrderResponseDTO> pageWithdrawOrders(WithdrawOrderQueryRequest withdrawOrderQueryRequest);

    /**
     * 统计用户成功提现的总金额
     *
     * @param userId
     * @return
     */
    BigDecimal queryUserTotalSuccessAmount(String userId);

    /**
     * 资金回退充值通知
     *
     * @param requestDTO
     */
    void backrollRechargeNotify(BackrollRechargeRequestDTO requestDTO);

    /**
     * 提现预提交阶段补单定时任务
     */
    void withdrawPreSubmissionJob();

    /**
     * 提现成功/失败定时任务T0
     */
    void withdrawSuccessFailureJobT0();

    /**
     * 提现成功/失败定时任务T1
     */
    void withdrawSuccessFailureJobT1();


    /**
     * 提现确认/取消定时任务
     */
    void withdrawConfirmCancelJob();

    /**
     * 平台提交提现申请
     *
     * @param requestDTO
     * @return
     */
    WithdrawOrderDTO plateFormSubmitWithdraw(SubmitWithdrawRequestDTO requestDTO);

    /**
     * 平台提现，异步回调，自动审核
     *
     * @param withdrawNotifyRequestDTO
     * @return
     */
    WithdrawNotifyResponseDTO processSubmitWithdrawPlateNotify(WithdrawNotifyRequestDTO withdrawNotifyRequestDTO);

    /**
     * 担保机构提交提现申请
     *
     * @param requestDTO
     * @return
     */
    WithdrawOrderDTO guaranteeSubmitWithdraw(OrgSubmitRequestDTO requestDTO);


    /**
     * 根据存管账户号查询该账户可快速到帐余额
     * @param accountNo
     * @param availableAmount
     * @return
     */
    BigDecimal getFastWithdrawEnableAmountByAccountNo(String accountNo,BigDecimal availableAmount);

    /**
     * 查询最近一次提现成功记录
     *
     * @param userId
     * @return
     */
    WithdrawOrderResponseDTO queryLastWithdrawSuccessRecord(String userId);

    /**
     * 根据提现订单ID查询提现订单
     * @param withdrawOrderId
     * @return
     */
	default WithdrawOrderResponseDTO getWithdrawOrderById(Long withdrawOrderId){
        throw new UnsupportedOperationException("unimplemented");
    }

    /**
     * 检查是否支持能T0提现
     *
     * @param userId
     * @param pushOrgId
     * @param userRoleEnum
     * @param withdrawAmount
     * @return
     */
    default WithdrawT0CheckResponse checkT0EnableWithOrg(String userId, String pushOrgId, UserRoleEnum userRoleEnum, BigDecimal withdrawAmount) {
        return null;
    }

    /**
     * 统计成功提现金额（账户）
     *
     * @param accountId 账户id
     * @return 提现金额
     */
    default BigDecimal statSuccessWithdrawAmount(Long accountId) {
        return null;
    }

    /**
     * 是否有提现中的订单
     * @param accountId
     * @return
     */
    default Boolean haveWithdrawingOrder(Long accountId){return false;}

    default BankInfoRespDTO getWithdrawingOrderBankInfo(Long bankCardId) {
        return null;
    }
}
